package com.company.service.impl;

import com.company.entity.User;
import com.company.service.BaseService;
import com.company.service.LoginService;
import com.company.utils.ServiceFactory;

import java.util.Scanner;

public class LoginServiceImpl implements LoginService {
    @Override
    public void execute() {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入用户名: ");
        String name = input.next();
        System.out.print("请输入密码: ");
        String pwd = input.next();
        System.out.print("请输入手机号: ");
        int phone = input.nextInt();
        SysUserServiceImpl sysUserService = new SysUserServiceImpl();
        int register = sysUserService.register(new User(name, pwd), phone);
        if (register==-1){
            System.out.println("登录成功!");
            BaseService type = ServiceFactory.getService("type");
            type.execute();
        }else{
            System.out.println("登录失败!");
        }
    }
}
